package JdbcUtilDemo;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
	private static ConfigManager configManager;
	private static Properties properties;
  /* 构造ConfigManager,读取jdbc.properties文件*/

	public ConfigManager(){
		String configFile="jdbc.properties";
		properties=new Properties();
		/*取得ConfigManager的类加载器，以流的方式的读取jdbc.properties文件*/
		InputStream is=ConfigManager.class.getClassLoader().getResourceAsStream(configFile);
		
		try{
			properties.load(is);
			is.close();
			
		}catch(IOException e){
			e.printStackTrace();
			
		}
		}
	
	/*  通过单例模式获取ConfigManager对象*/
	
	public static ConfigManager getInstance(){
		if(configManager==null){
			configManager=new ConfigManager();
		}
		return configManager;
	}
	/*获取jdbc.properties文件中的值*/
	
	
	public String getValues(String key){
		
		
		return  properties.getProperty(key);
	}
	
	
}
